class Date:
    def __init__(self, year, month, day):
        self.year = year
        self.month = month
        self.day = day

    def __str__(self):
        return f"{self.year}/{self.month}/{self.day:02}"

    # 静态方法
    @staticmethod
    def parse_date_str(date_str: str):
        return Date.parse_date_str_2(date_str)

    # 类方法，cls代表当前类本身，防止硬编码
    @classmethod
    def parse_date_str_2(cls, date_str: str):
        year, month, day = tuple(date_str.split("-"))
        return cls(int(year), int(month), int(day))


class User:
    # 私有属性 __xxx
    # 子类也无法直接获取到私有属性
    # 在python中，私有属性其实是python在执行的过程中对私有属性的名称进行了重命名：_类名__属性名称
    def __init__(self, birthday: Date):
    #    self.birthday = birthday
        self.__birthday = birthday

    def age_get(self):
        return 2022 == self.__birthday.year


if __name__ == '__main__':
    user = User(Date(2023, 12, 7))
    print(user.age_get())
    print(user._User__birthday) # 调用私有属性
